package com.zxh.system.service.impl;

import com.zxh.system.entity.User;
import com.zxh.system.repository.BaseRepository;
import com.zxh.system.repository.UserRepository;
import com.zxh.system.service.BaseService;
import com.zxh.system.service.UserService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Optional;

@Service("userService")
public class UserServiceImpl extends AbstractBaseServiceImpl<User> implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    protected BaseRepository getRepository() {
        return userRepository;
    }

    @Override
    public Optional<User> get(Serializable id) {
        return get("id",id);
    }

    @Override
    public User findByUsername(String username) {
        User u = userRepository.findByUsername(username);
        u.getAuthorities();
        return u;
    }

}
